vPCI/MSI-X: tidy init_msix()
authorJan Beulich <jbeulich@suse.com>
Tue, 5 Jan 2021 12:20:13 +0000 (13:20 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 5 Jan 2021 12:20:13 +0000 (13:20 +0100)
commit6fbb41258e9f733cd2b9254efae035c350d93920
tree28a88a6d80cc3423ef85cfab0d9dd29ca11697ab
parent4bac861340cf6551cfdac308621a984464701405
vPCI/MSI-X: tidy init_msix()

First of all introduce a local variable for the to be allocated struct.
The compiler can't CSE all the occurrences (I'm observing 80 bytes of
code saved with gcc 10). Additionally, while the caller can cope and
there was no memory leak, globally "announce" the struct only once done
initializing it. This also removes the dependency of the function on
the caller cleaning up after it in case of an error.

Also prefer a local variable over using a structure field previously
set from this very variable.

Finally move the call to vpci_add_register() ahead of all further
initialization of the struct, to bail early in case of error.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
xen/drivers/vpci/msix.c